<template>
  <div class="goods-list">
    <goods-list-item v-for="(item, index) in goods" :key="'goods' + index" :goodsItem="item"></goods-list-item>
  </div>
</template>

<script>
// 引入子组件
import GoodsListItem from "./GoodsListItem";

export default {
  name: "GoodsList",

  // 组件注册
  components: {
    GoodsListItem,
  },

  // 父组件传递数据
  props: {
    goods: {
      type: Array,
      default() {},
    },
  },
};
</script>

<style lang="less" scoped>
.goods-list {
  display: flex;

  // 让子元素根据大小换行显示
  flex-wrap: wrap;

  // 均等分
  // justify-content: space-evenly;

  // 均等分在一些移动端设备的浏览器上不能很好的支持, 所以我们换成两端对齐
  justify-content: space-between;
  padding: 10px 15px;
}
</style>